import qs from 'qs';
import axios from 'axios';

const baseURL = import.meta.env.APP_APIHOST;

const instance = axios.create({ baseURL: '' });

// 获取素材分类
export const getMaterialTypes = () => instance.get('/v1/category/list');

// 获取素材列表
export const getMaterials = (data: any) =>
  instance.get('/v1/material', { params: { ...data, status: 1 } });

// 获取产品介绍
export const getProductInfo = () => instance.get('/v1/productDesc/list');
// 发布内容
export const getContentList = (data: any) => instance.get('/v1/content/list', { params: data });
export const addContent = (data: any) => instance.post('/v1/content', data);
// 评论专区
export const getCommentList = (data: any) => instance.get('/v1/comment/list', { params: data });
export const addComment = (data: any) => instance.post('/v1/comment', data);
// 点赞
export const addLike = (data: any) => instance.post('/v1/like', data);
// 取消点赞
export const cancelLike = (data: any) => instance.delete('/v1/like/' + data.id);
// 获取推广内容
export const getNewsList = (data: any) => instance.get('/v1/news/list', { params: data });
export const getNewsDetail = (data: any) => instance.get('/v1/news/' + data.id);
// 获取聊天记录
export const getChatList = (data: any) => instance.get('/v1/chat/list', { params: data });
// 发送消息
export const addChat = (data: any) => instance.post('/v1/chat', data);
// 获取根据分类获取素材
export const getMaterialsByType = (data: any) =>
  instance.get('/api/materials?' + qs.stringify(data));

// 获取字体分类分类
export const getFontStyleTypes = () => instance.get('/api/font-style-types');

// 获取字体素材离别奥列表
export const getFontStyles = (data: any) => instance.get('/api/font-styles?' + data);

// 获取根据分类获取字体样式列表
export const getFontStyleListByType = (data: any) =>
  instance.get('/api/font-styles?' + qs.stringify(data));

// 获取字体分类分类
export const getTmplTypes = () => instance.get('/api/templ-types');
// 获取模板列表
export const getTmplList = (data: any) => instance.get('/api/templs?' + data);

// 获取banner
export const getBannerList = (data: any) => instance.get('/api/banners?' + data);
